## Public invitations Creating an invitation tied to a Public DID: ```typescript await agent.oob.createInvitation({ label: 'My Label', handshakeProtocols: [HandshakeProtocol.DidExchange, HandshakeProtocol.Connections], invitationDid: 'did:web:myhost.com', multiUseInvitation: !messages, imageUrl: 'https://myhost.com/myinvitationimage.png', messages, }) ``` `messages` are usually used in case we want to initiate a Proof Request or Credential Offer flow. For example: ```typescript const requestedAttributes: Record<string, AnonCredsRequestedAttribute> = {} requestedAttributes['schemaName'] = { names: ['name', 'age'], restrictions: [{ cred_def_id: 'credentialDefinitionId' }], } const request = await agent.proofs.createRequest({ protocolVersion: 'v2', proofFormats: { anoncreds: { name: 'proof-request', version: '1.0', requested_attributes: requestedAttributes }, }, }) const messages = [request] ``` On the receiver side, we can use `reuseConnection` in order to associate the incoming invitation to an existing connection we may have related to this public DID: ```typescript= const { outOfBandRecord } = await agent.oob.receiveInvitation(invitation, { autoAcceptInvitation: false, autoAcceptConnection: true, reuseConnection: true, }) ``` ## Implicit invitations The flow specified above needs the inviter to create a new invitation (even if it is related to a particular DID) every time. This is useful when we need to identify where the flow comes from (by i.e. looking at invitation id). But it is also possible for a public entity to simply accept DID Exchange requests without the need of creating invitations for each. This is what we call 'implicit invitations'. ```typescript let { connectionRecord: mediatorConnection } = await agent.oob.receiveImplicitInvitation({ did: 'did:web:mymediator.com#did-communication-1', alias: 'Mediator', autoAcceptConnection: true, }) if (!mediatorConnection) throw new Error('Mediator connection not created') mediatorConnection = await agent.connections.returnWhenIsConnected(mediatorConnection.id, { timeoutMs: 5000, }) ```