I have a Whatsapp template approved which includes a variable in the body text {{1}} and a variable in the URL of a button: https://[fixed-url]/`{{1}}`. Both variables were required to start with index 1 to get the template approved.
The code below works with templates with just one variable, without any buttons.
When I tried to add a second parameter, I am getting an error MessageBird\Exceptions\RequestException: An internal error occurred. It seems the variable for the button should not be submitted the same as regular variables, also given the index number.
While searching through the code, I'm not sure if buttons in templates with variables are supported in this library. Anybody would be able to confirm this? If so, I will look for alternatives to make this work.
EDIT: seems #121 is related. So not possible with the library out of the box...
$messageBird = new \MessageBird\Client('api_key'); // Set your own API access key here.
$param = new \MessageBird\Objects\Conversation\HSM\Params();
$param->default = 'XXXXX';
$language = new \MessageBird\Objects\Conversation\HSM\Language();
$language->policy = \MessageBird\Objects\Conversation\HSM\Language::DETERMINISTIC_POLICY;
$language->code = 'nl';
$hsm = new \MessageBird\Objects\Conversation\HSM\Message();
$hsm->templateName = 'name_template';
$hsm->namespace = 'namespace';
$hsm->params = array($param);
$hsm->language = $language;
$content = new \MessageBird\Objects\Conversation\Content();
$content->hsm = $hsm;
$message = new \MessageBird\Objects\Conversation\Message();
$message->channelId = 'channelid';
$message->content = $content;
$message->to = '31612345678';
$message->type = 'hsm';
try {
$conversation = $messageBird->conversations->start($message);
echo '<pre>';
var_dump($conversation);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
}
I have a Whatsapp template approved which includes a variable in the body text
{{1}}
and a variable in the URL of a button: https://[fixed-url]/`{{1}}`. Both variables were required to start with index 1 to get the template approved.The code below works with templates with just one variable, without any buttons. When I tried to add a second parameter, I am getting an error
MessageBird\Exceptions\RequestException: An internal error occurred
. It seems the variable for the button should not be submitted the same as regular variables, also given the index number.While searching through the code, I'm not sure if buttons in templates with variables are supported in this library. Anybody would be able to confirm this? If so, I will look for alternatives to make this work.
EDIT: seems #121 is related. So not possible with the library out of the box...