You will need an update to the application you've already published since you just built an integration. Now that you have finished building your integration, make sure to right-click once again on the main project folder in your Package Explorer, and go to Anypoint Platform, then click Deploy to Cloudhub. To do this, type the following code in DataWeave: Lastly, let’s add a Transform Message Component from the Mule Palette to our current flow to take the output payload from the Translator API and convert it to a plain text message for slack. Don’t forget to include your Bearer token in your Authorization header and set the Content-Type of the request to application/json. In the Body, set the output to JSON and format the query in the correct format for the Microsoft Translator API to understand. In this case, we will be translating the input language to Spanish. Make sure to include the API version and the to=* to whatever language you want the text to be translated to. Next, add a new HTTP Request Connector to the flow. Set the name to Token and set its value equal to the payload. Now that we are fetching the Bearer token from the Azure servers, let’s set that token as a variable so we can use it later. In your Headers, add your Ocp-Apim-Subscription-Key and set the value to Key 1 found in your Microsoft Azure portal. Next, add the issue-token URL in the Request URL field, change your Method to POST, and make sure the body is set to payload. First, drag the HTTP Request Connector from your Mule Palette and add it after your Set Variable component. This token is needed to send and receive API requests from the Translator API. Once we have stored the payload text as a variable, let’s authenticate and grab a Bearer token from the Microsoft servers. Name the variable textToTranslate and click the fx button and add DataWeave code to convert payload text message to JSON. Navigate back to Anypoint Studio and add a Set Variable component to the flow from the Mule Palette. Click the Create button as shown below and then grab your subscription keys. Once you are logged into the portal, go to All resources in the sidebar, click + Add and search the marketplace for Translator Text. To start, navigate to the Translator Text Signup signup and start a free trial. The next step to completing our Slack bot is to integrate the Microsoft Translator Text API into our Anypoint Studio project.
0 Comments
Leave a Reply. |