I use apiary for my REST service definitions and I will response a request parameter - in the case at the bottom I will resonse the {area} request parameter. Is there any syntax in the a.piary editor to do this? ({area} and $area does not work)
## StandbyService Phone API [/standby/phone/{area}]
### Phone[GET]
+ Response 200 (application/json)
[
{
"number": "00436760815",
"area": "{area}"
}
]
I am sorry to disappoint you, but it's currently not possible. Nevertheless, it's interesting idea, so we would be happy if you could share it on https://github.com/apiaryio/api-blueprint/issues with some details about your use case.
Related
My request body for an endpoint is so long:
1st question: I read that we can use some request.body.js file for storing our request body and then call it where ever we need it. But unfortunately, I could not find any sample framework/tutorial to learn it.
2nd question: in my project the properties of the request body (especially names of properties) are not exactly matching with the response body that is gaven in the Swagger document. What can be the reason? What would be your approach?
I would appreciate it if you could help me to ridd off the question in the best possible way. Thank you!
It's quite straight forward, take a look at this login example:
cy.fixture('users.json').then((userdata) => {
cy.request({
method: 'POST',
url: <auth_url>,
form: true,
body: userdata
});
});
You can export this as cypress function and then have it available in all your test spec files.
users.json file in fixtures folder looks like this:
{
"username": "...",
"password": "..."
}
Hope that answers the first question at least.
I've been reading the AWS Lex / Lambda docs and looking at the examples.
I don't see a way to return multiple lines.
I want to create an intent that when a user types 'Help' It gives me an output like below.
Options:
Deploy new instance.
Undeploy instance.
List instances.
I've tried this:
def lambda_handler(event, context):
logger.debug('event.bot.name={}'.format(event['bot']['name']))
a = {
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "Options: \nDeploy instance.\nUndeploy instance."
}
}
}
return a
How a message is displayed to the user completely depends on the output Channel you are using.
\n works well in Facebook and Slack that I know of.
The Lex Console Test Chat has its own unique formatting for displaying the Lex output, so its not very reliable for testing the formatting of a message. Its really only good for quick tests to make sure your bot responds without errors. And for a glimpse at the Lex JSON response.
Each output Channel will receive the Lex JSON response and display it in its own way, so the only reliable way to test message formatting, links, images, and response cards is to test it in the actual Channel.
I'm stuck in trying to figure this out and I hope someone out there can help me out. I am using the Dialogflow console to create a bot that requests a user to report "something" by providing his/her location and describing the incident. The bot is integrated with Facebook Messenger. One of my intents has a follow up intent which also has a follow up intent like:
intent 1
|
intent 2
| intent 3
Intent 1 requests for the user's location, intent 2 retrieves the user's location and asks the user to describe the location. Intent 3 SHOULD have all the data in context as it's fulfilled by the a webhook. All the data SHOULD be posted to my server. The problem is that I have failed to get the location data (maybe lat and long) I notice that the data comes back in the following format after the fired event FACEBOOK_LOCATION:
{
"originalDetectIntentRequest": {
"source": "facebook",
"payload": {
"postback": {
"data": {
"lat": 14.556761479425,
"long": 121.05444780425
},
"payload": "FACEBOOK_LOCATION"
},
"sender": {
"id": "1588949991188331"
}
}
}
My question is how to I carry that payload data into my Dialogflow Intent Parameters so that they are carried in context until my webhook is fired? I hope i've explained it well. Thanks for the help guys.
You can use the output contexts to save the parameters.
{
"fulfillmentText":"This is a text response",
"fulfillmentMessages":[ ],
"source":"example.com",
"payload":{
"google":{ },
"facebook":{ },
"slack":{ }
},
"outputContexts":[
{
"name":"context name",
"lifespanCount":5,
"parameters":{
"param":"param value"
}
}
],
"followupEventInput":{ }
}
Once you save the parameters, in the subsequent requests, you can access the parameters by accessing saved context. The lifespanCount will decide how many subsequent calls this context is valid. So in the above, eg. parameters saved in intent 1 will be available till intent 5 (if you have 2 more follow up intents)
You can follow more details here.
I personally like to use the client library to develop webhooks as they are easy to use, featureful and reduces JSON manipulation errors. If you like to use NodeJs based client, you can follow this link.
To expand on Abhinav's answer (and point out what caught me up on this issue). You need to make sure that the entities you extracted have the lifespan to make it to your webhook fulfillment call.
You can adjust the count by editing the number and saving.
The lifespanCount will decide how many subsequent calls this context is valid. - Abhinav
If your parameters are not showing up in your output context they probably don't have the appropriate lifespan.
I can't find any strict information about two requests with are made by Nexmo to "answer" end "event" services. I'm confused.
When I make a call to my virtual number first is my "answer" URL is called. Question is how JSON body of that request looks like? Can you provide me some example of that request to "answer" URL?
Then after welcome speach user make a choise and "event" service is called. As I understand JSON body for that POST request looks like that:
{
"dtmf": "2",
"timed_out": false,
"uuid": "cwa3126675f721esueedc762c9ft94b7",
"conversation_uuid": "CON-w4e9ae1-28ka-1234-ic63-65d022433343",
"timestamp": "2018-01-27T17:59:39.963Z"
}
Am I right?
Best regards,
Radek
The webhook to your answer event contains 4 values:
to: The endpoint being called.
from: The endpoint you are calling from.
conversation_uuid: The unique ID for this Conversation.
uuid: The unique ID for this Call.
By default this request is a GET and those will be query params, you can change the method to POST if you need it in that format and you will get JSON like this:
{
"from": "447700900001",
"to": "447700900002",
"uuid": "CON-9faebf2c-6609-40e2-adaa-95444b6ca352",
"conversation_uuid": "CON-9faebf2c-6609-40e2-adaa-95444b6ca352"
}
The 'Call Progress Events' reference is here, generally there are 2/3 different categories of events:
Call progess which is things like when the call is started answered & completed and then 2 other events which are in response to an input action or a record action.
https://developer.nexmo.com/api/voice#webhook
I must apologize it's currently not as easy as it should be to find this in our docs, but we've just started a rewrite of these pages and hopefully it will be much clearer soon.
I'm trying to make a request with Content-Type x-www-form-urlencoded that works perfectly in postman but does not work in Azure Logic App I receive a Bad Request response for missing parameters, like I'd not send enything.
I'm using the Http action.
The body value is param1=value1¶m2=value2, but I tried other formats.
HTTP Method: POST
URI : https://xxx/oauth2/token
In Headers section, add the below content-type:
Content-Type: application/x-www-form-urlencoded
And in the Body, add:
grant_type=xxx&client_id=xxx&resource=xxx&client_secret=xxx
Try out the below solution . Its working for me .
concat(
'grant_type=',encodeUriComponent('authorization_code'),
'&client_id=',encodeUriComponent('xxx'),
'&client_secret=',encodeUriComponent('xxx'),
'&redirect_uri=',encodeUriComponent('xxx'),
'&scope=',encodeUriComponent('xxx'),
'&code=',encodeUriComponent(triggerOutputs()['relativePathParameters']['code'])).
Here code is dynamic parameter coming from the previous flow's query parameter.
NOTE : **Do not forget to specify in header as Content-Type ->>>> application/x-www-form-urlencoded**
Answering this one, as I needed to make a call like this myself, today.
As Assaf mentions above, the request indeed has to be urlEncoded and a lot of times you want to compose the actual message payload.
Also, make sure to add the Content-Type header in the HTTP action with value application/x-www-form-urlencoded
therefore, you can use the following code to combine variables that get urlEncoded:
concat('token=', **encodeUriComponent**(body('ApplicationToken')?['value']),'&user=', **encodeUriComponent**(body('UserToken')?['value']),'&title=Stock+Order+Status+Changed&message=to+do')
When using the concat function (in composing), the curly braces are not needed.
First of all the body needs to be:
{ param1=value1¶m2=value2 }
(i.e. surround with {})
That said, value1 and value2 should be url encoded. If they are a simple string (e..g a_b) then this would be find as is but if it is for exmaple https://a.b it should be converted to https%3A%2F%2Fa.b
The easiest way I found to do this is to use https://www.urlencoder.org/ to convert it. convert each param separately and put the converted value instead of the original one.
Here is the screenshot from the solution that works for me, I hope it will be helpful. This is example with Microsoft Graph API but will work with any other scenario: