Skip to content

Firing a Signed Webhook Request #64

Description

@gja

There is no way to use this library currently to trigger a web hook to start a flow with message bird. Here is the code I'm using for this. I'll try to open a PR incorporating this sometime in the future.

moduleMessageBirdWebhookdefself.build_payload(time,body)parts=[]parts.push(time)parts.push("")parts.push(Digest::SHA256.new.digest(body))parts.join("\n")enddefself.sign_webhook_request(signing_key,body,now=Time.now)now=now.getutc.to_isignature=OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'),signing_key,build_payload(now,body)){"MessageBird-Request-Timestamp"=>now.to_s,"MessageBird-Signature"=>Base64.encode64(signature).strip,}enddefself.trigger_webhook(signing_key,webhook_id,params)body=params.to_jsonclient=Faraday.new(url: "https://flows.messagebird.com",headers: {'Content-Type'=>'application/json'})client.post("/flows/#{webhook_id}/invoke",body,sign_webhook_request(signing_key,body))endend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions