Nexmo API change on Text to Speech? - text-to-speech

For a very long time I've been using the following to send text-to-speech alerts from my applications.
curl 'https://api-us-1.nexmo.com/tts/json' \
-d api_key=****** \
-d api_secret=****** \
-d to=0035193xxxxxxx \
-d from=0035193xxxxxxx \
--data-urlencode 'text=Alert! Check Something... ' \
-d repeat=2 \
-d voice="male" \
Very recently the service has stopped working for some carriers.
While going over Nexmo docs I can't see the /tts/json API documented.
Anyone knows what happened?
Is the /tts/json API still usable?
The /v1/calls API is absolutelly overkill for my needs.

Unfortunately that API was sunset quite a while ago and replaced with the newer Voice API.
https://developer.nexmo.com/voice/voice-api/code-snippets/make-an-outbound-call-with-ncco would the closest alternative with the Voice API. The biggest change is switching to using a JWT for authentication versus the key/secret auth the older API used.
If you have the Nexmo CLI installed you can generate a JWT as part of a script. The following should work:
#!/bin/bash
#
# Send voice message to a user
#
# ./script.sh <number to call> <vonage number> "<message to speak>"
PATH_TO_PRIVATE_KEY=<path to private key>
VONAGE_APPLICATION_ID=<application ID>
TO_NUMBER=$1
VONAGE_NUMBER=$2
MESSAGE=$3
JWT=$(nexmo jwt:generate $PATH_TO_PRIVATE_KEY application_id=$VONAGE_APPLICATION_ID)
curl -X POST https://api.nexmo.com/v1/calls\
-H "Authorization: Bearer "$JWT\
-H "Content-Type: application/json"\
-d "{\"to\":[{\"type\": \"phone\",\"number\": \"$TO_NUMBER\"}],
\"from\": {\"type\": \"phone\",\"number\": \"$VONAGE_NUMBER\"},
\"ncco\": [
{
\"action\": \"talk\",
\"text\": \"$MESSAGE\"
}
]}"

Related

refreshing StubHub API tokens?

We are trying to refresh a previously working application's refresh tokens as per stub-hub's developers docs with the following commands (where <whatever> are account specific placeholders).
ENCRYPTED_ACCT=$(echo -n "<client-id>:<client-secret>" | base64);
curl -X POST "https://account.stubhub.com/oauth2/token" \
-u "${ENCRYPTED_ACCT}" --basic \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "refresh_token=<PREV_REFRESH_TOKEN>" \
--data-urlencode "scope=read:events";
In the past we've followed a similar flow (api changed since). But now with the recommended procedure the endpoint is failing due to invalid credentials for the ENCRYPTED_ACCT. Can anyone post a functioning workflow to refresh tokens of an existing account?

How to escape / in service name in thruk api call

I have lots of nagios services with forward slash in their names. When I try to acknowledge the service through thruk api, it returns error like below.
request: http://<thruk_url>/r/v1/services/test-host/check_disk_%2Fvar/cmd/acknowledge_svc_problem
response: /r/v1/services/test-host/check_disk_/var/cmd/acknowledge_svc_problem was not found on this server.
The service name is check_disk_/var. I have lots of services like these, thus renaming all of them is not an easy solution.
There is a generic command endpoint as described here:
https://thruk.org/documentation/rest_commands.html#_generic-command-endpoint
%> curl -H "X-Thruk-Auth-Key: ****" \
-d "cmd=acknowledge_svc_problem" \
-d "host=hostname" \
-d "service=servicedescription" \
-d "comment_data=test" \
'http://localhost/thruk/r/cmd'

Add two separate messages with circuit rest api in the same subject box

I am trying to write two different messages to the same subject bot after each other. But any time a new subject with the same title is posted.
I use the rest api post call and tried this:
curl --insecure -X POST https://yourcircuit.com/rest/v2/webhooks/incoming/xxxx -d '{"text": "foobar1", "subject": "My fancy title"}'
curl --insecure -X POST https://yourcircuit.com/rest/v2/webhooks/incoming/xxxx -d '{"text": "foobar2", "subject": "My fancy title"}'
I assumed two messages under the same title box inside the circuit conversation.
What is shows:
What I want to achive:
Does anybody know how to achive this?
That is not supported with webhooks. This could be done with the regular REST API /conversations/{convId}/messages/{itemId}. See https://circuitsandbox.net/rest/v2/swagger/ui/index.html
You can try this using the swagger ui at https://circuitsandbox.net/rest/v2/swagger/ui/index.html
Here is the corresponding http request:
curl -X POST "https://circuitsandbox.net/rest/v2/conversations/05bd75f1-a8d5-40c0-b24a-28710ec1a57f/messages/cde0b57e-7f1d-4ffb-b2af-a1b7c7c9fa06" \
-H "accept: application/json" \
-H "authorization: Bearer ot-4f70c19edc6f43c4b89b4d39b4440000" \
-H "content-type: application/x-www-form-urlencoded" \
-d "content=hello"
Note that the token above has been invalidated. You need to use your own conversation ID, parent item ID and access token.
And here is how it looks in Circuit:

How to use a Circuit Bot to publish a message in Circuit Conversation via Rest API Message

I am trying to make post a message in a circuit conversation through a Circuit Bot via Rest API call. Please help.
You have two options:
Use an incoming webhook. This is very simple and does not require OAuth as the webhook url includes token and the specific conversation. Anyone with this url can post to a conversation. There are both option, posting as yourself, or posting as a bot. If you want to post as a bot, then you first need to create a webhook bot using the "Manage Application > Custom Apps" page. For more information see https://www.circuit.com/unifyportalfaqdetail?articleId=164448 and other webhook articles on these FAQ pages.
Here is s curl example to post a message on an incoming webhook url.
curl https://circuitsandbox.net/rest/webhooks/incoming/9999999-0b95-4088-b272-5bef80f8e68e -H "Content-Type: application/json" -d '{"text":"hello world"}'
Create an actual OAuth 2.0 bot via "Manage Application > Custom Apps" and use the regular REST API (https://circuitsandbox.net/rest/v2/swagger/ui/index.html). There are several REST examples on github. See https://github.com/circuit/circuit-REST-bot for a simple REST bot example.
This is done in two steps :
use the authentication endpoint to obtain a token for your bot
use the messages endpoint (and the token from step 1) to publish the message
Assuming you already have :
a bot (client id, client secret)
conversation ID (the bot must be a participant of it)
Step 1 : Getting the token
curl -X POST
https://<circuitBaseUrl>/oauth/token \
-H 'Authorization: Basic <base64-encode(<clientId>:<clientSecret>)>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&scope=WRITE_CONVERSATIONS'
Get the access_token from the response
Step 2 : Use the REST API to post
curl -X POST \
https://<circuitBaseUrl>/rest/v2/conversations/<conversationId>/messages \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: beta.circuit.com' \
-d content=hello%20from%20postman
Welcome to the Circuit Developer Community ;-)

OneLogin API credentials

Im trying to make a basic call to the ONELOGIN API. After generating the cliend ID and secret with MANAGE ALL permissions, im still unable to connect
Generated correctly the ID and secret with the right permissions as per official documentation
curl 'https://api.us.onelogin.com/auth/oauth2/v2/token' \
-X POST \
-H "Authorization: client_id:, client_secret:" \
-H "Content-Type: application/json" \
-d '{
"grant_type":"client_credentials"
}'
i expected to connect, instaead the output is
{"status":{"error":true,"code":401,"type":"Unauthorized","message":"Authentication Failure"}}