

NOTE : Replace 8000 with the port your application is running on

Edit the routes/web.php file and add the following code: Before we do that, let’s add the webhook endpoint to our routes. We’ll be adding a Webhook URL to our Twilio account shortly. Twilio makes use of Webhooks to notify us whenever our bot receives a message. Next, the convertCurrency() method is called on the Currenc圜onverterClient class we created earlier to carry out the conversion. This method further calls the static method findB圜urrenc圜ode() on the Currency model to ensure that both codes are valid and are supported. The getCurrenc圜ode() method is then called passing in both currency codes.
#Whatsapp converter for mac code
Based on the agreed messaging format for our bot to work properly, it’s assumed that the items contained in the first index, second index, and fourth index of the array will be the amount, base currency code and the currency code the user is trying to convert to respectively.

Otherwise, if none of these conditions are met, a generic response format is sent back to the user informing them of the right messaging format to use with the bot. If the message contains the word “convert”, we’ll assume the user is trying to make a conversion and call the formatContentForConversion() method.
#Whatsapp converter for mac how to
If the content of the message sent to the bot contains the word “hello”, we send back a welcome message informing the user of how to make use of the bot. The determineMessageContent() method determines the kind of response the user receives.The response sent is dependent on the body of the message received. The MessagingResponse class from the Twilio SDK helps us to send the response in the right format. This is an XML-based language but we’re not required to create XML directly. Twilio expects this reply to be in Twilio Markup Language (TwiML). Once we have the message and apply our logic to determine the response, we need to send back a reply. The sendReplies() method will be called whenever our bot receives a message from WhatsApp.This is quite a long edit, but step-by-step we will go over what’s happening in this file so you can better understand. $currenc圜ode = Currency::findB圜urrenc圜ode($items) Private function getCurrenc圜ode(string $baseCurrency, string $currency) Return "We could not perform this conversion now, please bear with us"

If (strpos($formatContent, 'hello') != false) " Private function determineMessageContent(string $content) $content = $this->determineMessageContent($body) Public function sendReplies(Request $request) Run the following command in your terminal: For the sake of this tutorial, we’ll be using Composer. You can do so via the Laravel installer or by using Composer. There are different ways to set up a new Laravel project. You will need the following to complete this tutorial: In this tutorial, we’ll be looking at how we can build a WhatsApp Currency Conversion Bot for converting multiple currencies using the Twilio API for WhatsApp. With it’s over 1.5 billion users and growing, and familiar chat technology, WhatsApp presents a strong case for building a chatbot on it’s platform. Brands make use of bots as an exciting way to engage customers, while also providing a way to automate what could normally be considered, monotonous conversations. Over the years, we’ve seen a steady increase in the number of bots and chatbots available to us over different platforms.
